package com.tuteng.administrator.ashospital.Dialog;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.tuteng.administrator.ashospital.AdapterManger.NumberListAdapter;
import com.tuteng.administrator.ashospital.R;
import com.tuteng.administrator.ashospital.beans.FriendInfoBean;

import java.util.List;

public class Popwin {
/**
  public static   void   initPopWindow(PopupWindow popupWindow,View viewPager,Context context,List<FriendInfoBean>list,NumberListAdapter adapter,Activity activity){
        if (popupWindow == null) {
            // 创建一个PopupWindow对象
            // 设置PopupWindow要显示的内容
            ListView contentView = createListView(context,list,adapter,popupWindow,activity);
            // 设置PopupWindow的宽
            int width = 400;
            // 设置PopupWindow的高
            int height = 500;
            // 设置PopupWindow是否可以获取焦点
            boolean focusable = true;
            popupWindow = new PopupWindow(contentView, width, height, focusable);
            // 下面的两行代码是用于实现在点PopupWindow之外的地方的时候可以隐藏PopupWindow
            // 设置PopupWindow的外部可以点击
            popupWindow.setOutsideTouchable(true);
            popupWindow.setBackgroundDrawable(new ColorDrawable());
        }

        // 显示PopupWindow
        // 指定PopupWindow显示在哪个View的下方
        //  View anchor = et_number;
        // 指定PopupWindow的x方向的偏移量 xoff > 0向右偏移
        int xoff = 15;
        // 指定PopupWindow的y方向的偏移量 以et_number的底部为yoff = 0,yoff > 0向下偏移
        int yoff = -5;
        popupWindow.showAsDropDown( viewPager, 180, Gravity.CENTER_VERTICAL);
    }



   public static    ListView createListView(final Context contex, final List<FriendInfoBean>list, NumberListAdapter adapter, final PopupWindow popupWindow, final Activity activity) {
        ListView listView = (ListView) View.inflate(contex, R.layout.layout_number_list, null);


        adapter = new NumberListAdapter(contex,list);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) {
                Intent intent3=new Intent();
               Intent intent = intent3.setClass(contex, activity.class);
                Bundle bundle=new Bundle();
                bundle.putString("cardNo",list.get(position).getCardNo());
                intent3.putExtras(bundle);
              //  Toast.makeText(contex,"你点击的是"+i,Toast.LENGTH_SHORT).show();
                contex.startActivity(intent3);

                //  String number = (String) parent.getItemAtPosition(position);
                // et_number.setText(number);
                popupWindow.dismiss();
            }
        });
        return listView;
    }**/
}
